@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/receive_list";
		var _colnames = [
						"标题", 
						"发送人",
						"发送时间",
                        "状态",
        "操作"];
		var _colmodel = [
						{name:"title", index:"title", width:100},
						{name:"cname", index:"cname", width:100},
						{name:"ctime", index:"ctime", width:100},
						{name:"is_read", index:"is_read",formatter:fmtRead, width:100},
                        {name: 'id',formatter:fmatterOperation, width:200,sortable:false}
        ];


		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "is_read", order : "asc"}
		});
	}

	function  fmtRead(cellvalue, options, rowObject) {
        if (cellvalue==1){
            return '<span class="label label-sm label-success">已读</span>';
        }else{
            return '<span class="label label-sm label-warning">未读</span>';
        }
    }

    function fmatterOperation(cellvalue, options, rowObject){
        return '<button class="btn btn-primary btn-sm" onclick="view('+cellvalue+')">查看</button>';
    }

    function view(id){
        var index=layer.open({
            type: 2,
            title:"事务通知→通知查看",
            area: ["800px","520px"],
            fix: false, //不固定
            maxmin: true,
            content: ctx + "/${code}/receive_view/"+id
        });
    }
</script>

<div class="row">
    <div class="col-xs-12">
        <div class="row-fluid" style="margin-bottom: 5px;">
            <div class="tabbable">
                <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab4">
                    <li class="active" >
                        <a data-toggle="tab" href="#" onclick="javascript:window.location.href='${basePath}/${code}/receive'" aria-expanded="true">我收到的通知</a>
                    </li>
                    <li>
                        <a data-toggle="tab" href="#" onclick="javascript:window.location.href='${basePath}/${code}'" aria-expanded="false">我发出的通知</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			@ var _col=[
			@		{name:"标题", index:"title", type:"text"},
			@		{name:"通知发起人", index:"cname", type:"text"},
            @		{name:"发布时间(大于)",index:"ctime_gt", type:"date",placeholder:"发布时间(大于)",format:"YYYY-MM-DD"},
            @		{name:"发布时间(小于)",index:"ctime_lt", type:"date",placeholder:"发布时间(小于)",format:"YYYY-MM-DD"}
			@];
			@ include("/common/_function/_search2.html",{"col":_col}){}
			<!-- 按钮
			<div class="welljq well-sm" id="btns"></div>-->
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	
@}	